﻿﻿//======================================================================
//
//        Copyright : Zhengzhou Strawberry Computer Technology Co.,LTD.
//        All rights reserved
//        
//        Application:NRapid MVC framework
//        Filename :IndexController.cs
//        Description :首页控制器
//
//        created by Lucas at  2015-6-30`
//     
//        WebSite:http://www.NRapid.com
//
//======================================================================
using System;
using System.Collections.Generic;
using System.Web;
using NRapid.Advanced;

namespace WebApp.App.Web.Default.IndexController
{
    public class IndexAction  : Controller
	{
		public IndexAction(System.IO.TextWriter tw):base(tw){}
		public IndexAction(string fileName) : base(fileName) {}
		public IndexAction(Controller controller):base(controller){}
		public IndexAction(NRapid.Owin.HtmlWriter writer,IDictionary<string,string> cookies):base(writer,cookies){}public class __Index_users__:NRapid.Struct
		{
			public System.Int64 id;
			public System.String name;
			public System.String pwd;
			#region 写Json字符串
			public override void WriteJson(System.IO.TextWriter tw)
			{
				tw.Write("{");
						tw.Write("\"id\":");
						tw.Write(id.ToString());
						tw.Write(",");
						tw.Write("\"name\":");
						if(name==null)
						{
							tw.Write("null");
						}
						else
						{
							tw.Write("\"");
							tw.Write(name);
							tw.Write("\"");
						}
						tw.Write(",");
						tw.Write("\"pwd\":");
						if(pwd==null)
						{
							tw.Write("null");
						}
						else
						{
							tw.Write("\"");
							tw.Write(pwd);
							tw.Write("\"");
						}
				tw.Write("}");
			}
			#endregion
		}
		
        /// <summary>
        /// asdf
        /// </summary>
        /// <param name="a">is a</param>
        [CacheFile(300)]
        [GetHtmlZip("Index.html")]
        public void Index()
        {
            //这是变量b
            var con = new System.Data.SQLite.SQLiteConnection(NRapid.Config.ConfigurationManager.ConnectionStrings["Common"].ConnectionString);
			con.Open();
            #region	var users;选取所有记录
			var users = new NRapid.List<__Index_users__>();
			var __Index_users_command__ = new System.Data.SQLite.SQLiteCommand("select * from users", con);
			var __Index_users_reader__= __Index_users_command__.ExecuteReader();
			if (__Index_users_reader__.HasRows)
			{
				while (__Index_users_reader__.Read())
				{
					var __Index_users_temp__ = new __Index_users__();
					__Index_users_temp__.id = __Index_users_reader__.GetInt64(0);
					__Index_users_temp__.name =__Index_users_reader__.IsDBNull(1)?null: __Index_users_reader__.GetString(1);
					__Index_users_temp__.pwd =__Index_users_reader__.IsDBNull(2)?null: __Index_users_reader__.GetString(2);
					users.Add(__Index_users_temp__);
				}
			}
			__Index_users_reader__.Dispose();
			__Index_users_command__.Dispose();
			#endregion
			
            con.Close();
            
			Write("<!DOCTYPE html><html><head><meta name=\"viewport\" content=\"width=device-width\" /><title></title></head><body> 您好213123 </body></html>");
        }
    }
}